package com.card.user;

import java.util.Date;

import com.card.advice.Advice;
import com.card.advice.AdviceManager;
import com.card.main.CardOnline;
import com.xiaoao.net.utils.TimeUtils;

/**
 * 玩家反馈信息
 * @author hiChina
 *
 */
public class UserAdvice extends UserDataComponent{
	//最近提交日期
	private Date submitAdviceDate;

	public Date getSubmitAdviceDate(){
		return submitAdviceDate;
	}
	
	/**
	 * 
	 * @return 提交反馈结果
	 * 成功：SUBMIT_ADVICE_SUCCESS
	 * 反馈频繁：SUBMIT_ADVICE_TIME_LIMIT
	 * 反馈未能成功提交：SUBMIT_ADVICE_FAIL
	 */
	public int submitAdvice(String content){
		Date now=new Date();
		//如果玩家是第一次提交反馈信息
		if(submitAdviceDate==null){
			//记录反馈提交时间
//			this.submitAdviceDate=now;
			//将反馈信息插入到反馈信息表中
//			SetChanged();
		}
		Advice advice=new Advice(super.Context().getPrimaryKey(),content, now,CardOnline.ADVICE_STATE_VALID);
		AdviceManager.getInstance().sendNewAdvice(advice);
		return CardOnline.SUBMIT_ADVICE_SUCCESS;
//		else{
//			//如果距离上次反馈时间已有10分钟
//			if(TimeUtils.getDifferMinutes(submitAdviceDate, now)>=10){	
//				//记录反馈提交时间
//				this.submitAdviceDate=now;
//				//将反馈信息插入到反馈信息表中
//				Advice advice=new Advice(super.Context().getPrimaryKey(),content, now,CardOnline.ADVICE_STATE_VALID);
//				AdviceManager.getInstance().sendNewAdvice(advice);
//				SetChanged();
//				return CardOnline.SUBMIT_ADVICE_SUCCESS;
//			}
//			else{
//				return CardOnline.SUBMIT_ADVICE_TIME_LIMIT;
//			}
//		}
	}
}
